#include <stdio.h>  
  
const char* src_name= "1.txt";  
const char* dest_name= "2.txt";  
  
int main()  
{  
    FILE *src_fp;     
    if ((src_fp = fopen(src_name, "rb")) == NULL)  
    {     
        printf("fopen %s failed./n", src_name);  
        return -1;  
    }  
  	
    fseek(src_fp, 0L, SEEK_END);  
    int src_len = ftell(src_fp);  
    char *src_buf = new char[src_len];  
    fseek(src_fp, 0L, SEEK_SET);  
    fread(src_buf, src_len, 1, src_fp);  
    fclose(src_fp);  
  
    FILE *dest_fp;  
    if ((dest_fp = fopen(dest_name, "wb")) == NULL)  
    {     
        printf("fopen %s failed./n", dest_name);  
        return -1;  
    }  
    
    fwrite(src_buf, src_len, 1, dest_fp);  
    fclose(dest_fp);  
  
    return 0;  
}  
